package com.kucowka.otc.core;

import com.kucowka.otc.util.queue.PriorityQueue;

public class SimplePrinter implements Printer {

	private PriorityQueue queue;

	public SimplePrinter(PriorityQueue queue) {
		this.queue = queue;
	}

	public <T extends Comparable<T>> String asSortedString(T... values) {

		for (T value : values) {
			queue.insert(value);
		}

		StringBuilder sb = new StringBuilder();
		while (queue.size() > 0) {
			if (sb.length() > 0) {
				sb.append(", ");
			}
			sb.append(queue.popMax());
		}

		return sb.toString();
	}

}
